<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../css/mui.min.css">
		<script src="../js/mui.min.js"></script>
		<script src="../js/app.js"></script>
		<style>
			html,body {
				background-color: #efeff4;
			}
		</style>
		<script>
			mui.init();
		</script>
	</head>

	<body>

<style>
	html,
	body,
	.mui-off-canvas-wrap {
		height: 100%;
		overflow: hidden;
	}
</style>
<div class="mui-off-canvas-wrap mui-draggable">
	<div class="mui-inner-wrap">
		<header class="mui-bar mui-bar-nav">
			<a href="#offCanvas" class="mui-icon mui-icon-bars mui-pull-left"></a>
			<a class="mui-action-back mui-btn mui-btn-link mui-pull-right">关闭</a>
			<h1 class="mui-title">右滑导航</h1>
		</header>
		<aside id="offCanvas" class="mui-off-canvas-left">
			<button id="offCanvasHide" class="mui-btn mui-btn-primary mui-btn-block">
				关闭侧滑菜单(js call)
			</button>
			<ul class="mui-table-view mui-table-view-chevron mui-table-view-inverted">
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right">
						Item 1
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right">
						Item 2
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right">
						Item 3
					</a>
				</li>
			</ul>
		</aside>
		
		<div id="scroll" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<button id="offCanvasShow" class="mui-btn mui-btn-primary mui-btn-block">
					显示侧滑菜单(js call)
				</button>
				<ul class="mui-table-view mui-table-view-chevron">
					<li id="switch" class="mui-table-view-cell">
						整体滑动
						<div class="mui-switch mui-active">
							<div class="mui-switch-handle"></div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron">
					<li class="mui-table-view-cell mui-media">
						<a class="mui-navigate-right">
							<img class="mui-media-object mui-pull-left" src="../images/42x42.gif">
							<div class="mui-media-body">
								Item 1
								<p>
									Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore. Lorem ipsum dolor sit amet.
								</p>
							</div>
						</a>
					</li>
					<li class="mui-table-view-cell mui-media">
						<a class="mui-navigate-right">
							<img class="mui-media-object mui-pull-left" src="../images/42x42.gif">
							<div class="mui-media-body">
								Item 1
								<p>
									Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore. Lorem ipsum dolor sit amet.
								</p>
							</div>
						</a>
					</li>
					<li class="mui-table-view-cell mui-media">
						<a class="mui-navigate-right">
							<img class="mui-media-object mui-pull-left" src="../images/42x42.gif">
							<div class="mui-media-body">
								Item 1
								<p>
									Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore. Lorem ipsum dolor sit amet.
								</p>
							</div>
						</a>
					</li>
					<li class="mui-table-view-cell mui-media">
						<a class="mui-navigate-right">
							<img class="mui-media-object mui-pull-left" src="../images/42x42.gif">
							<div class="mui-media-body">
								Item 1
								<p>
									Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore. Lorem ipsum dolor sit amet.
								</p>
							</div>
						</a>
					</li>
					<li class="mui-table-view-cell mui-media">
						<a class="mui-navigate-right">
							<img class="mui-media-object mui-pull-left" src="../images/42x42.gif">
							<div class="mui-media-body">
								Item 1
								<p>
									Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore. Lorem ipsum dolor sit amet.
								</p>
							</div>
						</a>
					</li>
					<li class="mui-table-view-cell mui-media">
						<a class="mui-navigate-right">
							<img class="mui-media-object mui-pull-left" src="../images/42x42.gif">
							<div class="mui-media-body">
								Item 1
								<p>
									Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore. Lorem ipsum dolor sit amet.
								</p>
							</div>
						</a>
					</li>
				</ul>
			</div>
		</div>
		<!-- off-canvas backdrop -->
		<div class="mui-off-canvas-backdrop"></div>
	</div>
</div>
<script>
	mui.init({
		swipeBack: false,
	});
	mui('#scroll').scroll();
	var offCanvasContainer = document.querySelector('.mui-off-canvas-wrap');
	var offCanvasInnerContainer = offCanvasContainer.querySelector('.mui-inner-wrap');
	var offCanvas = mui('#offCanvas');
	document.getElementById('switch').addEventListener('toggle', function(event) {
		if (event.detail.isActive) { //整体滑动时，侧滑菜单在inner-wrap内
			offCanvasInnerContainer.insertBefore(offCanvas[0], offCanvasInnerContainer.firstElementChild);
		} else { //仅主内容滑动时，侧滑菜单在off-canvas-wrap内
			offCanvasContainer.insertBefore(offCanvas[0], offCanvasContainer.firstElementChild)
		}
	});
	document.getElementById('offCanvasShow').addEventListener('tap', function() {
		//offCanvas.offCanvas('toggle')//toggle or show;
		offCanvas.offCanvas('show');
	});
	document.getElementById('offCanvasHide').addEventListener('tap', function() {
		//offCanvas.offCanvas('toggle')//toggle or hide;
		offCanvas.offCanvas('hide');
	});
</script>

</body>
</html>